package com.my.study.config.hook.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * <p>Bean初始化完成扩展点</p>
 * <p>Spring也支持通过构造函数注入，我们可以把搞事情的代码写在构造函数中，同样能达到目的
 * </p>
 *
 * @author: yidujun
 * @create: 2021/04/02 16:39
 */
@Component
@Slf4j
public class LogicInConstructorExampleBean {

    private final Environment environment;

    @Autowired
    public LogicInConstructorExampleBean(Environment environment) {
        this.environment = environment;
        log.info("LogicInConstructorExampleBean -> {}", Arrays.asList(environment.getDefaultProfiles()));
    }
}
